<?php 

namespace App\Http\Controllers\Api;

use Illuminate\Routing\Controller as BaseController;
use Stripe\StripeClient;

class StripeController extends BaseController
{
	// ？ 是否缓存，是否$stripe->paymentIntents->update
	public function index()
	{
		// 支付请求主要代码
		$stripe = new StripeClient(env('SCRIPE_SECRET_KEY'));

		$paymentIntent = $stripe->paymentIntents->create([
			'amount' => 1099,
			'currency' => 'bif',
			'payment_method_types' => [
			  'card',
			],
			'confirmation_method' => 'manual',
		]);

		// var_dump($paymentIntent->client_secret);

		// $stripe->paymentIntents->save();

		$stripe->paymentIntents->confirm(
			$paymentIntent->id,
			['payment_method' => 'pm_card_visa']
		);

	}

	public function success()
	{
		echo 'success';
	}

	public function cancel()
	{
		echo 'cancel';
	}
}



